feat(github): add github trending adapter#1953
Open
leo1in88 wants to merge 1 commit into
Open
Conversation
Add a PUBLIC adapter that lists repositories from https://github.com/trending — the trending view is a public HTML page with no official REST API, so the data was previously unreachable through opencli. The adapter fetches the page server-side (no browser, no auth) and parses each repo's full name, description, primary language, total stars, forks, and stars gained in the period. Flags: - `--since` daily | weekly | monthly (default daily) - `--language` filter by language slug, e.g. python, rust, "c++" - `--limit` 1..25 (GitHub lists at most 25) Typed errors: ArgumentError for bad --since / --limit, CommandExecutionError on request/HTTP failure, EmptyResultError when the page yields no repos. Tests cover parsing (stars/forks/language/description/url, missing language), limit truncation, language+since URL building, argument validation, the empty-result path, and non-ok HTTP. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
GitHub's Trending view (https://github.com/trending) has no official REST API — it's a server-rendered HTML page — so opencli had no way to surface it. This adds a
github trendingadapter that lists trending repositories.Strategy
PUBLIC(browser: false). The page is public HTML, no login or token. The adapter fetches it server-side withfetchand parses eacharticle.Box-rowfor: full name, description, primary language, total stars, forks, and stars gained in the period. No third-party deps (plain regex parsing).Flags
--sincedaily/weekly/monthlydaily--languagepython,rust,"c++", …)--limit1..25(GitHub lists at most 25)25Columns
rank, repo, description, language, stars, forks, starsSince, urlTyped errors
ArgumentError— invalid--sinceor out-of-range--limitCommandExecutionError— network failure / non-2xx HTTPEmptyResultError— page returned no repositoriesUsage
Test plan
npx vitest run --project adapter clis/github/trending.test.js→ 8 passing: parsing (stars/forks/language/description/url + missing language → null),--limittruncation, language+since URL building (/trending/rust?since=weekly), argument validation, empty-result path, non-ok HTTP.npx tsc --noEmit→ clean.cli-manifest.jsonregenerated vianpm run build-manifest(adds the new command).🤖 Generated with Claude Code